In a digital camera or the like, automatic white balance adjustment is performed so that the color of a subject that is white under a given light source is reproduced as white. Available white balance adjustment methods include a method in which the balance of RGB components of a signal for each pixel is adjusted so that an average for an entire image represents an achromatic color. In another known technique, an image is divided into a plurality of blocks, an average value of RGB components is calculated for each block, only one or more blocks whose average values fall within a predetermined range are extracted, and the RGB components are adjusted so that an average value of RGB components for a group of the extracted blocks represents an achromatic color.
Further, Japanese Patent Laid-Open Publication No. 2000-92509 discloses a technique wherein an image is divided into a plurality of blocks, a representative value is calculated for each block, and representative values for all blocks are used to calculate white balance gain.
FIG. 12 is a block diagram showing the structure of a related-art white balance adjustment device. An image capture device 10, such as a digital camera, captures an image and outputs the captured image to a block-dividing circuit 12.
The block-dividing circuit 12 divides an input image into equal blocks. Each block contains “n by m” pixels. The block-dividing circuit 12 sequentially outputs the blocks to a representative value calculating circuit 14.
The representative value calculating circuit 14 calculates an average value of RGB components for n * m pixels constituting each block, and further calculates a representative value (Tl, Tg, Ti) from the block average value, by means of the following linear transformation:
                              (                                                    Tl                                                                    Tg                                                                    Ti                                              )                =                              (                                                                                1                    /                    4                                                                                        1                    /                    2                                                                                        1                    /                    4                                                                                                                                          -                      1                                        /                    4                                                                                        1                    /                    2                                                                                                              -                      1                                        /                    4                                                                                                                                          -                      1                                        /                    2                                                                    0                                                                      1                    /                    2                                                                        )                    ⁢                      (                                                            R                                                                              G                                                                              B                                                      )                                              (        1        )            where Tl represents the luminance of a block, and Tg and Ti represent the color difference of a block. The representative value calculating circuit 14 outputs the representative values (Tl, Tg, Ti) calculated for each block to a white balance evaluating circuit 16.
The white balance evaluating circuit 16 evaluates the reliabilities of the respective blocks, calculates weighting factors in accordance with the evaluated reliabilities, and outputs the weighting factors to a white balance gain calculating circuit 18. For example, the reliabilities are evaluated using experience-derived knowledge regarding various types of light sources. The higher the subject luminance, the smaller the value to which a weighting factor is set for a particular block (a block that is highly likely to be illuminated by a fluorescent lamp) using experience-derived knowledge that, when the luminance of a subject is extremely high, the light source is less likely to be a fluorescent lamp.
The white balance gain calculating circuit 18 calculates a white balance gain value by performing a weighted average using the representative values of the blocks, and the weighting factors calculated by the white balance evaluating circuit 16 from the reliabilities of the blocks. More specifically, white balance gains are calculated by the following equations:
                              (                                                    RMix                                                                    GMix                                                                    BMix                                              )                =                              (                                                            1                                                                      -                    1                                                                                        -                    1                                                                                                1                                                  1                                                  0                                                                              1                                                                      -                    1                                                                    1                                                      )                    ⁢                      (                                                            TlMix                                                                              TgMix                                                                              TiMix                                                      )                                              (        2        )            MaxMix=max (RMix, GMix, BMix)   (3)Rgain=MaxMix/RMixGgain=MaxMix/GMix   (4)Bgain=MaxMix/BMixwhere TlMix, TgMix, and TiMix represent weighted average values obtained from the representative values of the blocks. The value (RMix, GMix, BMix) calculated by the above equations represents the color of a light source illuminating the subject. The white balance gains Rgain, Ggain, and Bgain are adjusted so that the color obtained when light coming from an estimated light source is reflected from a white object is corrected to be gray (or, in other words, so that R=G=B is satisfied). The calculated gains are output from the white balance gain calculating circuit 18 to a white balance adjusting circuit 20.
The white balance adjusting circuit 20 multiplies RGB pixel values for each pixel included in an image input from the image capture device 10 by the respective gains calculated by the white balance gain calculating circuit 18, thereby adjusting the white balance of the image to output the result thereof.
However, the above-described related art technique involves a problem in that, because a representative value for each block is calculated using equation (1) based on an average value of RGB components obtained for all n * m pixels included in each block, when a certain color of an object present within a block differs from the color of a light source, the average value of the block will be influenced by the color of this object.
As an example, FIG. 13 shows a block 100, which is one of a plurality of blocks into which an image is divided. The block 100 includes n * m pixels, and a simple average of RGB components for all the pixels is calculated as the average value for this block. However, as shown in this figure, the block 100 includes an image 102 of a green leaf In such a case, because the background color and the green color are averaged, the resultant average value does not accurately indicate the color of a light source illuminating the block. As a result, there may arise a situation in which, although the light source should be determined as daylight, the light source can be erroneously determined as a fluorescent lamp.
As described, related-art techniques do not always provide sufficient measures for estimating the color of an actual light source in cases where an object of a chromatic color is present within a block, or in cases where a state within a block is not uniform (for such cases, although the reliability of each block can be used to lower the unwanted influence, this requires accurate evaluation of the reliability), and this failure to provide sufficient measures has been a factor causing reduced accuracy of white balance adjustment.
An objective of the present invention is to provide a device that is capable of performing white balance adjustment reliably even in cases where an object of a chromatic color is present within a block, or cases where a state within a block is not uniform.